﻿using System;
using System.IO;

using Gamey.Settings;

namespace Gamey
{
    public class Env
    {
        public static readonly string GameyDirectoryPath;
        public static readonly string GameySettingsPath;
        public static readonly GameySettings GameySettings;

        static Env()
        {
            GameyDirectoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Gamey");
            var mammyDirectory = new DirectoryInfo(GameyDirectoryPath);

            if (!mammyDirectory.Exists)
            {
                mammyDirectory.Create();
            }

            GameySettingsPath = Path.Combine(GameyDirectoryPath, "settings.xml");
            if (File.Exists(GameySettingsPath))
            {
                GameySettings = GameySettings.Load(GameySettingsPath);
            }
            else
            {
                GameySettings = new GameySettings();
            }
        }

        public static GameySettings Settings
        {
            get { return GameySettings; }
        }

        public static void SaveSettings()
        {
            Settings.Save(GameySettingsPath);
        }
    }
}
